<%-- 
    Document   : ReporteGrafica
    Created on : 1/07/2013, 08:10:44 PM
    Author     : dev
--%>

<%@page import="com.mycompany.ayd2_fase2.conexion"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        
        <title>Reporte Grafica</title>
        
        
        <style type="text/css" media="screen">
            <%@include file="Plantilla/style.css"%>
        </style>
        
        <script type="text/javascript">
            (function() {
                var t = document.createElement('script'); t.type = 'text/javascript'; t.async = true;
                t.src = "//turnsocial.com/bar/0b51054a20af7df5e0f9a2ab0c7df35a.js";
                var s = document.getElementsByTagName('script')[0];
                s.parentNode.insertBefore(t, s);
            })();
        </script>
        <script type="text/javascript" src="javascript/piecanvas.js"></script>
    </head>
    <body>
        <div id="bg">
            <div id="outer">
                <div id="header">
                    <div id="logo">
                        <h1>
                            <a href="#">EduShare</a>
                        </h1>
                    </div>
                    <div id="nav">
                        <ul>
                             <li class="first active">
                                <a href="Gestionar_Articulo_Administrador_Super.jsp">Articulo</a>
                            </li>
                            <li>
                                <a href="Gestionar_Usuario.jsp">Usuario</a>
                            </li>
                            <li>
                                <a href="Denuncias_Admin_Super.jsp">Denuncias</a>
                            </li>
                            <li>
                                <a href="ReporteXTema.jsp">Reportes</a>
                            </li>
                            <li>
                                <a href="#">FAQ</a>
                            </li>
                            <li>
                                <a href="index.jsp">Cerrar Sesión</a>
                            </li>
                        </ul>
                            <br class="clear" />
                    </div>
                </div>
                <div id="main">
                    <div id="sidebar">
                        <ul class="linkedList">
                        <li class="first">
                                <a href="ReporteXTema.jsp">Top 5 por Tema</a>
                        </li>
                        <li class="last">
                                <a href="ReporteGrafica.jsp">Grafico Barra % de Publicaciones</a>
                        </li>
                        </ul>
                    </div>
                    <div id="content">
                        <div id="box1">
                           <center><h2><font color="8E8177">
                                Porcentaje De Articulos Realizados Por Publicadores
                            </font></h2></center>
                            <canvas id="canvas1" width="400" height="400" title="title attribute">
                                <table id="tablota" class="datatable">
    <%
        conexion cn = new conexion("root", "admin", "edushare");
        Connection conectado = cn.getConexion();
        
        if(conectado != null){
            String strquery = "SELECT U.u_alias as nick, count(P.a_idarticulo) as total " +
                "FROM Usuario U, Publicacion P " +
                "WHERE P.u_idusuario = U.u_idusuario " +
                "AND U.u_tipousuario = 1 " +
                "GROUP BY nick " +
                "ORDER BY total DESC, nick";
            
            Statement st = (Statement) conectado.createStatement();
            ResultSet rs = st.executeQuery(strquery);
            
            while(rs.next()){
                String nick = rs.getString(1);
                String total = rs.getString(2);
                
                out.println("<tr><td>" + nick + "</td><td>" + total + "</td></tr>");
            }
            
        }
    %>
                                </table>
                            </canvas>
                            <script type="text/javascript">piechartcanvas('tablota','canvas1','#444887', 1);</script>
                        </div>
                        <br class="clear" />
                    </div>
                    <br class="clear" />
                </div>
            </div>
        </div>
    </body>
</html>
